﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using BussinessLayer;

namespace projectQLDV
{
    public partial class frmDoanVienThamGiaHoatDong : DevExpress.XtraEditors.XtraForm
    {
        frmMain frmM;
        tblhoatdong hd = new tblhoatdong();
        tblchidoan cd = new tblchidoan();
        public frmDoanVienThamGiaHoatDong(frmMain frm)
        {
            InitializeComponent();
            frmM = frm;
            
            cbxNamhoc();
        }
        public void gridlookupEdit()
        {
            DataTable dthd;
            if(comboBoxNamhoc.Text=="")
               dthd = hd.SelectAllhoatdong();
            else
                dthd = hd.SelectAllhoatdongNamhoc(comboBoxNamhoc.Text);
            dthd.Columns.Add("STT");
            for (int i = 0; i < dthd.Rows.Count; i++)
                dthd.Rows[i]["STT"] = i + 1;
            gridLookUpEditLCTD.Properties.DataSource = dthd;
            //gridLookUpEditHS_GV.Properties.DisplayMember = "hoten";
            //gridLookUpEditHS_GV.Properties.ValueMember = "id";
        }

        private void frmDoanVienThamGiaHoatDong_FormClosed(object sender, FormClosedEventArgs e)
        {
            frmM.frmDVThamGiaHD_isShown = false;
        }
        private void cbxNamhoc()
        {
            DataTable tbchidoan = new DataTable();
            tbchidoan.Clear();
            comboBoxNamhoc.Items.Clear();
            tbchidoan = cd.SelectAllchidoan();
            string _temp = "";
            string code;
            if (tbchidoan.Rows.Count > 0)
            {

                foreach (DataRow row in tbchidoan.Rows)
                {
                    code = row["namhoc"].ToString();

                    if (_temp != code)
                    {
                        comboBoxNamhoc.Items.Add(code);
                        _temp = code;
                    }
                   

                }
            }
        }

        private void gridLookUpEditLCTD_MouseDown(object sender, MouseEventArgs e)
        {
            gridlookupEdit();
        }

        private void simpleButton1_Click(object sender, EventArgs e)
        {

        }

       
    }
}